<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>系统管理</title>

    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <script th:src="@{/js/jquery-1.9.1.min.js}"></script>
    <style type="text/css">
        .layui-tab-title .layui-this {
            color: #009688;
        }
        body {
            background-color: #ffffff;
            overflow-x:hidden;
            overflow-y: hidden;
        }

    </style>
</head>
<body>

<table class="layui-table" lay-data="{ url:'/admin/queryAllJob', page:true, id:'idTest'}" lay-filter="demo">
    <thead>
    <tr>
        <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
        <th lay-data="{field:'id', width:60, sort: true, fixed: true}">ID</th>
        <th lay-data="{field:'uid', width:90}">发布人ID</th>
        <th lay-data="{field:'jobName', width:150}">工作名称</th>
        <th lay-data="{field:'jobComClass', width:120}">发布者类型</th>
        <th lay-data="{field:'jobDate', width:240, sort: true}">发布时间</th>
        <th lay-data="{field:'jobDeadline', width:130, sort: true}">截止时间</th>
        <th lay-data="{field:'number', width:100}">投递人数</th>
        <th lay-data="{field:'orUse', width:120}">状态(1正常)</th>
        <!--<th lay-data="{field:'wealth', width:135, sort: true}">财富</th>-->
        <!--<th lay-data="{field:'score', width:80, sort: true, fixed: 'right'}">评分</th>-->
        <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}"></th>
    </tr>
    </thead>
</table>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">状态</a>
</script>

<script th:src="@{/layui/layui.all.js}"></script>
<script>
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                window.open("/job/job?id="+data.id);
                //layer.alert('ID：'+ data.id + '<br>'+ JSON.stringify(data));
            } else if(obj.event === 'del'){
                layer.confirm('确定更改发布状态?', function(index){
                    //obj.del();
                    $.ajax({
                        url:"/admin/jobOrUser",
                        type:"post",
                        data:{"id":data.id},
                        success:function (result) {
                            layer.open({
                                content: result,
                                yes: function(index){
                                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                                    window.location.reload();
                                }
                            });
                        }
                    })
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.msg('编辑权限归用户所有')
            }
        });

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
</body>
</html>
